package chapter8;

/**
 * Created by LinGer on 2019/6/18
 */
public class JoinTest extends Thread{

    public JoinTest(String name){
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.getName() + " start");
        for (int i = 0; i < 10000; i++) {
            //延时操作
        }
        System.out.println(this.getName() + " finish");
    }

    public static void main(String[] args) {
        try{
            JoinTest t1 = new JoinTest("t1");
            t1.start();
            //将t1加入到主线程main中，并且主线程会等待t1完成后才退出
            t1.join();
            System.out.println(Thread.currentThread().getName() + " FINISH");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
